
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.common.dto.CommonQaInfoDTO;
import com.insigma.business.qrcode.common.dto.CommonQaInfoInsertRequest;
import com.insigma.business.qrcode.common.dto.CommonQaInfoSearchRequest;
import com.insigma.business.qrcode.intell.dto.CommonQaInfoBSearcher;
import com.insigma.business.qrcode.intell.entity.CommonQaInfoDO;
import com.insigma.business.qrcode.soldier.request.CommonQaInfoUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonQaInfoProviderConverter extends AbstractConverter<CommonQaInfoDTO, CommonQaInfoDO> {

    private final static CommonQaInfoProviderConverter commonQaInfoConverter = new CommonQaInfoProviderConverter();

    private CommonQaInfoProviderConverter(){}

    
    public static CommonQaInfoBSearcher convertRequestSO2Searcher(final CommonQaInfoSearchRequest request){
        final CommonQaInfoBSearcher commonQaInfoBSearcher = new CommonQaInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonQaInfoBSearcher);
        return commonQaInfoBSearcher;
    }

    
    public static List<CommonQaInfoDTO> convertResponseDOList2DTOList(final List<CommonQaInfoDO> commonQaInfoDOList){
        return commonQaInfoConverter.convertGenericResponseDOList2DTOList(commonQaInfoDOList);
    }

    
    public static CommonQaInfoDTO convertResponseDO2DTO(final CommonQaInfoDO commonQaInfoDO){
        return commonQaInfoConverter.convertGenericResponseDO2DTO(commonQaInfoDO);
    }

    @Override
    protected CommonQaInfoDTO doConvertResponseDO2DTO(CommonQaInfoDO commonQaInfoDO) {
        final CommonQaInfoDTO commonQaInfoDTO = new CommonQaInfoDTO();
        try {
            BeanUtils.copyProperties(commonQaInfoDO, commonQaInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonQaInfoDTO;
    }

    public static CommonQaInfoDO convertRequestIO2DO(final CommonQaInfoInsertRequest commonQaInfoInsertRequest) {
        final CommonQaInfoDO commonQaInfoDO = new CommonQaInfoDO();
        BeanUtils.copyProperties(commonQaInfoInsertRequest,commonQaInfoDO);
        return commonQaInfoDO;
    }

    public static CommonQaInfoDO convertRequestUO2DO(final CommonQaInfoUpdateRequest commonQaInfoUpdateRequest) {
        final CommonQaInfoDO commonQaInfoDO = new CommonQaInfoDO();
        BeanUtils.copyProperties(commonQaInfoUpdateRequest,commonQaInfoDO);

        return commonQaInfoDO;
    }

}
